package com.mini.utils;

import com.baidu.aip.ocr.AipOcr;
import org.json.JSONObject;

import java.util.HashMap;

/**
 * @author 白sa能
 * @className
 * @date Created in 11:49 AM 5/3/21
 * @package com.mini.utils
 * @Description
 */
public class AipOCR {
    //设置APPID/AK/SK
    public static final String APP_ID = "24104474";
    public static final String API_KEY = "OkTcCs2Vmcp54WK6r4750SF1";
    public static final String SECRET_KEY = "dC4y4Cqsoh1YDtIYNaSIokDTh1LEvOwZ";

    public static void main(String[] args) {
        // 初始化一个AipOcr

    }

    public static String verify(String url) {
        AipOcr client = new AipOcr(APP_ID, API_KEY, SECRET_KEY);
        // 传入可选参数调用接口
        HashMap<String, String> options = new HashMap<>();
        options.put("language_type", "CHN_ENG");
        options.put("detect_direction", "true");
        options.put("detect_language", "true");
        options.put("probability", "true");

        // 通用文字识别, 图片参数为远程url图片
        JSONObject res = client.basicGeneralUrl(url, options);
        return res.toString(2);

    }
}
